home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
libs
/
knowhow4
/
iconmenu.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-10
|
3KB
|
105 lines
#include "iconmenu.h"
void IconMenu::calcItemsNumber()
{
for(count = 0; itemList[count] != 0; count++)
;
itemSize = pScreenSet->icon_types[itemType];
}
/////////////////////////
void IconMenu::showItem()
{
rect where = getItemCoord();
Icon icon(loc(where.origin.X + itemDistance.X / 2,
where.origin.Y + itemDistance.Y / 2),
itemList[pos - 1], itemType);
imageP image = icon.extract();
putimage(where.origin, image, COPY_PUT);
delete image;
}
/////////////////////////
/* show() is not absolutely necessary here. Remark it if you
intend to use computers with fast disk operations (cash).
If show() remarked, the ChoiseBox::show() will use calls to
showItem(), and each call will open - close icon file.
*/
void IconMenu::show()
{
Window::show();
Window::clrscr();
if(!available || (itemStrings == NULL && itemList == NULL))
return;
Icon icon(loc(0, 0), itemList[pos - 1], itemType);
FILE* iconFile;
char* fileName = strdup(icon.icon_open());
if((iconFile = fopen(fileName, "r+b")) == NULL)
{
delete fileName;
return;
}
int p = pos;
for(int i = 1; i <= raw; i++)
{
for(int j = 1; j <= column; j++)
{
pos = start + (i - 1) * column + j - 1;
loc size = icon_size(itemType);
int i_size = ((size.X + 1 + 7) >> 3 << 2) * (size.Y + 1) + sizeof(imageP);
imageP image = (imageP)malloc(i_size + 10);
get_image(iconFile, itemList[pos - 1],
image, i_size);
rect where = getItemCoord();
putimage(where.origin, image, COPY_PUT);
delete image;
if(pos == count)
break;
}
if(pos == count)
break;
}
fclose(iconFile);
delete fileName;
pos = p;
moveTo(pos);
}
///////////////////////////
/*
void main()
{
if(!init_KNOW_HOW())
return;
setfillstyle(SOLID_FILL, pColorSet->colors.BAK_COLOR);
bar(0, 0, getmaxx(), getmaxy());
int LIST[] = { 1, 2, 3, 1, 2, 3, 3, 2, 1, 2, 0 };
IconMenu i(rect(10, 10, 30, 16), "window.pcy", "ICON MENU",
"0123456789", 1, 1, SMALL_ICON, LIST, loc(3, 3),
rect(60, 20, 79, 25), MEDIUM_ICON, NULL, LIST,
FIXED, 10, SHOW_BORDER, SHOW_BORDER, 21, 22);
i.show();
i.exe();
i.hide();
IconMenu i0(rect(10, 10, 50, 20), "window.pcy", "ICON MENU",
"0123456789", 1, 1, MEDIUM_ICON, LIST, loc(5, 8),
rect(60, 20, 79, 25), MEDIUM_ICON, NULL, LIST,
FIXED, 10, SHOW_BORDER, SHOW_BORDER, 23, 24);
i0.show();
i0.exe();
i0.hide();
IconMenu i1(rect(10, 4, 70, 20), "window.pcy", "ICON MENU",
"0123456789", 1, 1, LARGE_ICON, LIST, loc(5, 8),
rect(60, 20, 79, 25), MEDIUM_ICON, NULL, LIST,
FIXED, 10, SHOW_BORDER, SHOW_BORDER, 25, 26);
i1.show();
i1.exe();
i1.hide();
close_KNOW_HOW();
closegraph();
}
*/